package edu.cueb.wmis.mapper;

import edu.cueb.wmis.pojo.Incomebill;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.PathVariable;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author liuzizhuo
 * @since 2021-04-19
 */
public interface IncomebillMapper extends BaseMapper<Incomebill> {


    @Select("SELECT i.* FROM tb_incomebill i LEFT JOIN tb_incomebillitem ib ON i.`id`=ib.`billId` WHERE goodId = #{id}")
//    @Results(id = "incomebill",value = {
//           @Result(id=true,column = "id",property = "id"),
//            @Result(column = "billName",property = "billName"),
//            @Result(column = "inputTime",property = "inputTime"),
//            @Result(column = "inputUserId",property = "inputUserId")
//    })
    Incomebill getIncomeBillByGoodId(@Param("id") Integer id);

    @Select("SELECT id FROM tb_incomebill")
    List<Integer> selectAllInbillId();
    @Select("SELECT ib.* FROM tb_incomebill ib , tb_incomebillitem ii WHERE ib.`id` = ii.`billId` AND goodId = #{goodId}")
    Incomebill getInbillByGoodId(Integer goodId);
    @Select("SELECT COUNT(*) FROM tb_incomebill WHERE billName LIKE CONCAT('%',#{year},'%')")
    Integer findMaxBillName(String year);
}
